
<template>
<div class="app-container">
  <el-form ref="form" :inline="true" :model="search" label-width="100">
    <el-form-item label="订单名称">
      <el-input v-model="search.orderNo"></el-input>
    </el-form-item>
    <el-form-item label="订单状态">
      <el-select v-model="search.status" placeholder="请选择订单状态">
        <el-option label="未支付" value="0"></el-option>
        <el-option label="已支付" value="1"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">查询</el-button>
      <el-button type="primary" @click="clearForm">重置</el-button>
    </el-form-item>
  </el-form>

  <el-table
    :data="tableData"
    style="width: 100%">

    <el-table-column
      prop="orderNo"
      label="订单号"
      >
    </el-table-column>

    <el-table-column
      prop="totalFee"
      label="订单金额(分)"
      >
    </el-table-column>

    <el-table-column
      prop="status"
      label="订单状态">
      <template slot-scope="scope">
        {{scope.row.status=='0'?'未支付':'已支付'}}
      </template>
    </el-table-column>
    <el-table-column
      prop="eduCreate"
      label="创建时间"
    >
    </el-table-column>
  </el-table>
  <el-pagination
    background
    :current-page="page.pageNum"
    layout="prev, pager, next"
    @current-change="handleCurrentChange"
    :page-count="page.pages">
  </el-pagination>
</div>
</template>
<script >

import orders from "../api/orders";
import cookie from "js-cookie";

export  default{
  layout:'menu',
  data(){
    return{
      form:{},
     search:{
       orderNo:'',
       status:''
     },
      page:{
       pageNum:1,
        pageSize:2,
        pages:0,
        total:0
      },
      tableData:[],
    }
  },
  methods:{
    getPage(){
     orders.getOrder(this.search,this.page,this.form.mobile).then(resp=>{
        this.tableData=resp.data.records
        this.page.pageNum=resp.data.current
        this.page.pageSize=resp.data.size
        this.page.total=resp.data.total
        this.page.pages=resp.data.pages
      })
    },
    onSubmit(){
      this.page.pageNum=1
      this.getPage()
    },
    clearForm(){
      this.search={
        orderNo:'',
        status:''
      }
      this.onSubmit()
    },
    handleCurrentChange(val){
      this.page.pageNum=val
      this.getPage()
    },
    getSelect(){
      var userStr=cookie.get("front_member")
      if (userStr){
        this.loginInfo=JSON.parse(userStr)
        console.log(this.loginInfo)
        this.form=this.loginInfo
      }
    },
  },
  created() {

    this.getSelect()
    this.getPage()
  }
}

</script>
<style scoped>

</style>
